class Solution:
    def findMaximumXOR(self, nums: list) -> int:
        res, mid = 0, 0
        for i in range(31, -1, -1):
            mid |= (1 << i)
            mid_set = set()
            for num in nums:
                mid_set.add(num & mid)
            tan = res | (1 << i)
            # tan = res + (1 << i)
            for num in mid_set:
                if tan ^ num in mid_set:
                    res = tan
                    break
        return res


a = Solution()
print(a.findMaximumXOR([3, 10, 5, 25, 2, 8]))

# DD = list()
# while len(DD) < 1024:
#     DD.append("*")
